__author__ = 'Dianlei Zhang'

from multiprocessing import Process
import os

# 子进程要执行的代码
def run_proc(name):
    print('Run child process %s (%s)...' % (name, os.getpid()))
    for j in range(10):
        print("parent thread ,Cj = %s" %j)

def run_proc2(name):
    print('Run child process %s (%s)...' % (name, os.getpid()))
    for j in range(10):
        print("parent thread ,Cj2 = %s" %j)

if __name__=='__main__':
    print('Parent process %s.' % os.getpid())
    for i in range(10):
        print("parent thread ,Pi = %s" %i)

    p = Process(target=run_proc, args=('test',))
    p2 = Process(target=run_proc2, args=('test',))
    print('Child process will start.')
    p2.start()
    p.start()
    p.join()
    p2.join()
    print('Child process end.')